#!/bin/bash

# update libseccomp
rpm -e libseccomp-2.3.1-4.el7.x86_64 --nodeps
wget http://rpmfind.net/linux/centos/8-stream/BaseOS/x86_64/os/Packages/libseccomp-2.5.1-1.el8.x86_64.rpm
rpm -ivh libseccomp-2.5.1-1.el8.x86_64.rpm
rpm -qa | grep libseccomp

# install nerdctl-full
#wget https://gh.api.99988866.xyz/https://github.com/containerd/nerdctl/releases/download/v1.0.0/nerdctl-full-1.0.0-linux-amd64.tar.gz

# install containerd
wget https://github.com/containerd/containerd/releases/download/v1.5.11/cri-containerd-cni-1.5.11-linux-amd64.tar.gz

tar -C / -zxvf cri-containerd-cni-1.5.11-linux-amd64.tar.gz

sudo mkdir -p /etc/containerd
#containerd config default | sudo tee /etc/containerd/config.toml
containerd config default > /etc/containerd/config.toml

# config
sed -i 's#k8s.gcr.io#registry.aliyuncs.com/google_containers#' /etc/containerd/config.toml

sed -i 's#SystemdCgroup = false#SystemdCgroup = true#' /etc/containerd/config.toml

#sed -i 's#/var/lib/containerd#/data/containerd#' /etc/containerd/config.toml
#      [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
#        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
#          endpoint = ["https://docker.mirrors.ustc.edu.cn"]
#        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.gcr.io"]
#          endpoint = ["https://registry.aliyuncs.com/google_containers"]

systemctl restart containerd
systemctl enable containerd
systemctl status containerd


ctr version
containerd --version

# config crictl
cat > /etc/crictl.yaml << EOF
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
debug: false
EOF

systemctl restart containerd
systemctl status containerd


